﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OF.Common;
using System.Data;

namespace OF.Web.admin
{
    public partial class login : System.Web.UI.Page
    {
        OF.BLL.User.Seller bll_seller = new BLL.User.Seller();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string name = txtname.Text.Trim();
            string pwd = txtpwd.Text.Trim();
            if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(pwd))
            {
                tip.InnerText = "用户名或密码不能为空";
                tip.Style.Add(HtmlTextWriterStyle.Display, "block");
                return;
            }
            DataSet ds = bll_seller.GetList("loginname='" + txtname.Text + "' and pwd ='" +txtpwd.Text  + "'"); //Utils.Md5(txtpwd.Text)
            if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
            {
               string state= ds.Tables[0].Rows[0]["state"].ToString();
               if (Convert.ToInt32(state) != 2)
               {
                   WebUtils.AddSession(txtname.Text, ds.Tables[0].Rows[0]["id"].ToString());
                   Response.Redirect("index.aspx");
               }
               else {
                   MessageBox.Show(this, "店铺已经关闭");
               }
            }
            else 
            {
                MessageBox.Show(this,"用户名或密码不正确");
            }
        }
    }
}